package edu.fudan.jwxt.Aspect;

import edu.fudan.jwxt.Exception.ServiceException;
import edu.fudan.jwxt.common.Constants;
import edu.fudan.jwxt.common.DataConfig;
import lombok.Data;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class CourseAspect {

//    定义切面表达式
//     @???("@???(edu.fudan.jwxt.annotation.EnableSelectCourse)")
//     public void SelectCourseCheck(){}

    @Pointcut("@annotation(edu.fudan.jwxt.annotation.EnableSelectCourse)")
    public void SelectCourseCheck(){}
//     TODO: 对注解SelectCourseCheck的SelectCourseCheck()方法进行环绕增强
@Around(value = "SelectCourseCheck()")
public Object SelectCourseAround(ProceedingJoinPoint pjp) throws Throwable {
    // 判断是否是选课时间
    if(!DataConfig.enableSelectCourse)
        throw new ServiceException("不在选课范围内","1");
    return pjp.proceed();
}
}
